package com.example.houqin_oa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.comment_oa.pojos.rear.Pos;
import com.example.comment_oa.pojos_vo.LogisticsVo.PosVo;
import com.example.comment_oa.pojos_vo.flowableVo.taskVo;
import com.example.houqin_oa.mapper.DetailsMapper;
import com.example.houqin_oa.service.PosService;
import com.example.houqin_oa.mapper.PosMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author liang
* @description 针对表【pos】的数据库操作Service实现
* @createDate 2023-02-05 12:36:36
*/
@Service
public class PosServiceImpl extends ServiceImpl<PosMapper, Pos>
    implements PosService{
    @Autowired
    PosMapper posMapper;

    @Autowired
    DetailsMapper detailsMapper;

    //采购订单和详情的新增
    @Override
    public boolean AddIndent(PosVo posVo) {
        posVo.setPosApplyTime(new Date());
        posVo.setPosApprovalState("0");
        posVo.setPosState("0");
        boolean pos = POs(posVo);
        boolean details = AddPODetails(posVo);
        if (pos && details){
            return true;
        }else {
            return false;
        }
    }
    //采购订单查询
    @Override
    public List<Pos> AllPos(Pos pos) {
        return posMapper.AllPos(pos);
    }

    @Override
    public Pos conPos(Pos pos) {
        return posMapper.conPos(pos);
    }

    @Override
    public boolean upPos(taskVo t) {
        Pos pos = new Pos();
        pos.setPosNo(t.getBianhao());
        pos.setPosApprovalTime(new Date());
        if(t.getApprovd()){
            pos.setPosApprovalState("1");
        }else {
            pos.setPosApprovalState("2");
        }

        return posMapper.rewPos(pos);
    }

    //采购订单新增
    public boolean POs(PosVo posVo){
        return posMapper.POs(posVo);
    }
    //采购订单详情新增
    public boolean AddPODetails(PosVo posVo){
        return detailsMapper.AddPODetails(posVo);
    }
}




